﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeetCode
{
    public class ReverseInteger : IRun
    {
        //给出一个 32 位的有符号整数，你需要将这个整数中每位上的数字进行反转。

        public void Run()
        {
            Method1(1231);
        }

        public void Method1(int x)
        {
            int PM;
            if (x > 0)
                PM = 1;
            else
            {
                PM = -1;
                x = x * -1;
            }
            string sx = x.ToString();
            char[] char1 = new char[sx.Length];
            for (int i = 0; i < char1.Length; i++)
            {
                char1[i] = sx[char1.Length - i - 1];
            }

            string _Result = string.Join("",char1);

            if (!int.TryParse(_Result, out x))
            {
                x = 0;
            }
            else
            {
                x = PM * x;
            }
        }
    }
}
